<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">点击改变</button>
    <button class="box">点击改变</button>
    <button class="box">点击改变</button>
    <button>点击改变</button>
    <script>
        var oBtn=document.getElementById("btn");
        oBtn.onclick=function(){
            this.style.backgroundColor="red";
        }

        var oBtns=document.getElementsByClassName("box")[0];
        var oBtns1=document.getElementsByClassName("box")[1];
        oBtns.onclick=function(){
            this.style.backgroundColor="skyblue";
        }
        oBtns1.onclick=function(){
            this.style.backgroundColor="yellowgreen";
        }


        var oBtns2=document.getElementsByTagName("button")[3];
        oBtns2.onclick=function(){
            this.style.backgroundColor="yellow";
        }
    </script>
</body>
</html>